package cn.sciento.boot.tenant.controller.v1;

import cn.sciento.swagger.annotation.Permission;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import cn.sciento.boot.tenant.dto.TenantInitProcessContext;
import cn.sciento.boot.tenant.service.TenantInitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("tenantInitProcessController.v1")
@RequestMapping({"/v1/tenant-init"})
public class TenantInitProcessController {
  @Autowired
  private TenantInitService tenantInitService;
  
  @ApiOperation("租户初始化处理器")
  @Permission(permissionWithin = true)
  @PostMapping({"/process"})
  public ResponseEntity process(@ApiParam("租户初始化处理上下文") @RequestBody TenantInitProcessContext tenantInitProcessContext) {
    this.tenantInitService.process(tenantInitProcessContext);
    return ResponseEntity.ok("success");
  }
}
